<template>
	<view class="index">
		<!-- #ifdef H5 -->
		<YouRan-UI-WeiXinNei-TiShi></YouRan-UI-WeiXinNei-TiShi>
		<!-- #endif -->
		<template v-if="JSON.stringify(QieHuanKa_PeiZhi) != '{}'">
			<template v-if="QieHuanKa_PeiZhi.KaiQi">
				<scroll-view
					style="position: fixed;top: 0;left: 0;z-index: 999999;text-align: center;"
					class="YouRan-UI-XuanXiangKa-1"
					scroll-x="true">
					<view
						v-if="QieHuanKa_PeiZhi.LieBiao[0].KaiQi"
						@click="DianJi_QieHuanKa(1)"
						:class="QieHuanKa == 1 ? ' Zt-YuanSe' : ' Zt-ZhanWeiSe'"
						class="XunHuan H3 H3-Line">{{QieHuanKa_PeiZhi.LieBiao[0].BiaoTi}}</view>
					<view
						v-if="QieHuanKa_PeiZhi.LieBiao[1].KaiQi"
						@click="DianJi_QieHuanKa(2)"
						:class="QieHuanKa == 2 ? ' Zt-YuanSe' : ' Zt-ZhanWeiSe'"
						class="XunHuan H3 H3-Line">{{QieHuanKa_PeiZhi.LieBiao[1].BiaoTi}}</view>
					<view
						v-if="QieHuanKa_PeiZhi.LieBiao[2].KaiQi"
						@click="DianJi_QieHuanKa(3)"
						:class="QieHuanKa == 3 ? ' Zt-YuanSe' : ' Zt-ZhanWeiSe'"
						class="XunHuan H3 H3-Line">{{QieHuanKa_PeiZhi.LieBiao[2].BiaoTi}}</view>
					<view
						v-if="QieHuanKa_PeiZhi.LieBiao[3].KaiQi"
						@click="DianJi_QieHuanKa(4)"
						:class="QieHuanKa == 4 ? ' Zt-YuanSe' : ' Zt-ZhanWeiSe'"
						class="XunHuan H3 H3-Line">{{QieHuanKa_PeiZhi.LieBiao[3].BiaoTi}}</view>
					<view
						v-if="QieHuanKa_PeiZhi.LieBiao[4].KaiQi"
						@click="DianJi_QieHuanKa(5)"
						:class="QieHuanKa == 5 ? ' Zt-YuanSe' : ' Zt-ZhanWeiSe'"
						class="XunHuan H3 H3-Line">{{QieHuanKa_PeiZhi.LieBiao[4].BiaoTi}}</view>
				</scroll-view>
				<view style="padding-top: 82rpx;"></view>
			</template>
		</template>
		
		<view v-if="QieHuanKa == 1">
			<YouRan-UI-DIY v-if="YouRan_UI_DIY_ZhuangTai" :PeiZhi_WenJian="PeiZhi_WenJian"></YouRan-UI-DIY>
			
		</view>
		<view v-if="QieHuanKa == 2">
			<YouRan-UI-ShouCang-LieBiao></YouRan-UI-ShouCang-LieBiao>
		</view>
		<view v-if="QieHuanKa == 3">
			<YouRan-UI-GuanZhu-LieBiao></YouRan-UI-GuanZhu-LieBiao>
		</view>
		<view v-if="QieHuanKa == 4">
			<YouRan-UI-YongHu-LieBiao :PeiZhi_WenJian="PeiZhi_WenJian"></YouRan-UI-YongHu-LieBiao>
		</view>
		<view v-if="QieHuanKa == 5">
			<YouRan-UI-PingLun-LieBiao :PeiZhi_WenJian="PeiZhi_WenJian"></YouRan-UI-PingLun-LieBiao>
		</view>
		<!-- 尾部右侧悬浮按钮 -->
		<view
			@click="$_TiaoZhuan('_Z_GongYong/CaoGao_LieBiao','Token')"
			class="CaoGao-AnNiu">
			<text class="ShuLiang" v-if="DangQian_CaoGao_ShuLiang">{{DangQian_CaoGao_ShuLiang}}</text>
			<text class="iconfont icon-yanchu1"></text>
		</view>
		<view
			@click="$_TiaoZhuan('_FaBu/_FaBu?LeiXing=ChuangJian','Token')"
			class="FaBu-AnNiu">
			<text class="iconfont icon-edit-filling"></text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				DangQian_CaoGao_ShuLiang:"",
				PeiZhi_WenJian:"FaXian.json",// [ ！很重要！] 请求哪个 Json 文件
				YouRan_UI_DIY_ZhuangTai:true,// YouRan-UI-DIY 组件的状态，用来重载
				QieHuanKa_PeiZhi:{},
				QieHuanKa:1,
			}
		},
		mounted() {
			uni.$on('ChongXinQingQiu',(data) => {
				this.YouRan_UI_DIY_ZhuangTai = false;
				setTimeout(() => {
					this.YouRan_UI_DIY_ZhuangTai = true;
				}, 100);
			})
		},
		onShow() {
			// 是否有消息
			this.$_ShiFou_You_XiaoXi()
			// 获取草稿数量
			this.$_QingQiu(
				"GET","/api/v2/editor/post/drafts",{},
				(res) => {
					this.DangQian_CaoGao_ShuLiang = res.data.data.paginate.total;
				}
			)
			uni.getStorage({
				key: 'TongZhi_ShangYiYe',
				success: (res) => {
					this.YouRan_UI_DIY_ZhuangTai = false;
					setTimeout(() => {
						this.YouRan_UI_DIY_ZhuangTai = true;
						uni.removeStorage({ key: 'TongZhi_ShangYiYe' });
					}, 100);
				}
			});
		},
		onLoad() {
			this.QingQiu_BenYe_PeiZhi();
		},
		methods: {
			QingQiu_BenYe_PeiZhi(){
				uni.request({
					url:this.$_PeiZhi_WenJian() + "FaXian.json",
					method:'GET',
					success: (res) => {
						this.QieHuanKa_PeiZhi = res.data.QieHuanKa;
						this.QieHuanKa = res.data.QieHuanKa.ShouPing;
					}
				})
			},
			DianJi_QieHuanKa(e){
				if(e == 2 || e == 3){
					if(uni.getStorageSync('ZhangHaoXinXi') && uni.getStorageSync('YongHuXinXi')){
						this.QieHuanKa = e;
					}else{
						uni.showToast({
							title:"未登录，请先登陆",
							icon:"none",
							duration:1000
						});
					}
				}else{
					this.QieHuanKa = e;
				}
			}
		},
		// 下拉，加载
		onPullDownRefresh() {
			this.QieHuanKa = 1;
			this.YouRan_UI_DIY_ZhuangTai = false;
			setTimeout(() => {
				this.YouRan_UI_DIY_ZhuangTai = true;
				uni.stopPullDownRefresh();
			}, 100);
		},
	}
</script>

<style lang="scss">
.index{
	.FaBu-AnNiu{
		position: fixed;
		right: 25rpx;
		// #ifdef H5
		bottom: 150rpx;
		// #endif
		// #ifndef H5
		bottom: 25rpx;
		// #endif
		box-shadow: 0 0 18rpx #DDD;
		width: 100rpx;
		height: 100rpx;
		border-radius: 100rpx;
		z-index: 999;
		background: #FFF;
		display: flex;
		align-items: center;
		justify-content: center;
		text{
			font-size: 50rpx;
			color: $LanSe;
		}
	}
	.CaoGao-AnNiu{
		position: fixed;
		right: 25rpx;
		// #ifdef H5
		bottom: 280rpx;
		// #endif
		// #ifndef H5
		bottom: 150rpx;
		// #endif
		box-shadow: 0 0 18rpx #DDD;
		width: 100rpx;
		height: 100rpx;
		border-radius: 100rpx;
		z-index: 999;
		background: #FFF;
		.icon-yanchu1{
			width: 100rpx;
			height: 100rpx;
			font-size: 50rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			color: $JuHuang;
			position: absolute;
			top: 0;
			left: 0;
			z-index: 1;
		}
		.ShuLiang{
			background: $HongSe;
			font-size: 18rpx;
			line-height: 18rpx;
			color: #FFF;
			width: 30rpx;
			height: 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			position: absolute;
			right: 0;
			top: 0;
			z-index: 2;
			border-radius: 100rpx;
		}
	}
}
</style>